package service

import (
	"errors"
	"gin/common"
	"gin/model"
)

func CreateRoleGroup(data model.RoleGroup) (model.RoleGroup, error) {
	_, err := data.Insert()
	return data, err
}

func FindRoleGroup(Param common.SelectQueryParam) (resData model.RoleGroup, err error) {
	var logModel model.RoleGroup
	resData, err = logModel.Find(Param)
	return
}

func SelectRoleGroup(Param *common.SelectQueryParam) (total int64, resData []model.RoleGroup, err error) {
	var logModel model.RoleGroup

	total, resData, err = logModel.Select(Param)

	return
}

func UpdateRoleGroup(Data model.RoleGroup) (model.RoleGroup, error) {
	if Data.Id <= 0 {
		return Data, errors.New("id required")
	}
	return Data.Update(Data)
}

func DeleteRoleGroup(param *common.Filter) {
	var logModel model.RoleGroup
	logModel.DeleteByFilter(param)
	return
}
